import sys, os, flask, time
from owlready2 import *

default_world.set_backend(filename = "/tmp/t.sqlite3", exclusive = False)

onto = get_ontology("http://test.org/onto.owl")

with onto:
  class C(Thing): pass
  default_world.save()


app = flask.Flask("OwlreadyBench")

@app.route("/gen")
def gen():
  with onto:
    for i in range(5):
      c = C()
      c.label = [os.getpid()]
      print(c, c.storid)
    default_world.save()
  return ""

@app.route("/test")
def test():
  time.sleep(0.02)
  nb = len(list(C.instances()))
  return "%s %s" % (os.getpid(), nb)